/**   
            * 脚本名称：页面加载Loading脚本    
            * by 小萧 490489876
            * 脚本引入时，脚本应放到body内，否则报错；   
            * 使用方法：load.loading.add("加载中，请稍候"); //可带文字可不带文字
            * 删除方法：  load.loading.remove();
            */
            var loads = window.whir || {};
            loads.loading =
                {
                    add: function (title, city) {
                        city = city == undefined ? 1 : city;
                        console.log(city);
                        function createStyle(){ 
                            console.log(city);
                            if (city == '1') {// loading 样式一 默认显示这个
                                return ".loading-mask {position: absolute;z-index: 2000;background-color: hsla(0, 0%, 100%, .9);margin: 0;top: 0;right: 0;bottom: 0;left: 0;transition: opacity .3s}.amt_load{ transition: all 1s;-moz-transition: all 1s;-webkit-transition: all 1s;-o-transition: all 1s;}.droploading{display: inline-block;position: absolute;top: 5px;left: -38px;height: 22px;width: 22px;border-radius: 100%;margin: 6px;border: 2px solid #409eff;border-bottom-color: transparent;vertical-align: middle;-webkit-animation: rotate 0.75s linear infinite;animation: rotate 0.75s linear infinite;}@-webkit-keyframes rotate {0% {-webkit-transform: rotate(0deg);}50% {-webkit-transform: rotate(180deg);}100% {-webkit-transform: rotate(360deg);}}@keyframes rotate {0% {transform: rotate(0deg);}50% {transform: rotate(180deg);}100% {transform: rotate(360deg);}}"
                            } 
                        }
                        function addStyle(){
                            var style = document.createElement("style");
                            style.type = "text/css";
                            style.innerHTML = createStyle();
                            window.document.head.appendChild(style);
                        }
                        addStyle();// 页面加入样式

                        // opacity = opacity == undefined ? 1 : opacity;
                        var arr = this.getPageSize();
                        var width = parseInt(arr[2]);
                        var height = parseInt(arr[3]);
    
                        //背景遮罩    
                        var mask = document.createElement("div");
                        mask.id = 'mask';
                        mask.className = 'loading-mask amt_load';
                        mask.addEventListener('touchstart', function (e) { e.preventDefault(); }, false);   //触摸事件    
                        mask.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);    //滑动事件    
                        mask.addEventListener('touchend', function (e) { e.preventDefault(); }, false);     //离开元素事件    
                        document.body.appendChild(mask);
                        
                        if (city == '1') {//loading 样式 一 默认一
                            //提示文本    
                            var loading = document.createElement("div");
                            loading.id = 'loading-tit';
                            loading.style.position = 'absolute';
                            loading.style.left = (width / 2 -50) + "px";
                            loading.style.top = (height / 2 -50) + "px";
                            loading.style.width = 'auto';
                            loading.style.height = "50px";
                            loading.style.lineHeight = "50px";
                            loading.style.display = "inline-block";
                            loading.style.fontSize = " 0.5em";
                            loading.style.textAlign = "center";
                            loading.style.fontFamily = " initial";
                            loading.style.zIndex = "100001";
                            loading.style.color = "#444";
                            title = (title != undefined && title.length > 0) ? title : "";
                            loading.innerHTML = title;
                            document.getElementById('mask').appendChild(loading);
                            var loadings = document.createElement("div");
                            loadings.id = 'droploading';
                            loadings.className = 'droploading';
                            document.getElementById('loading-tit').appendChild(loadings);
                        } 
                      
                        //先隐藏0.5s，之后再展示
                        mask.style.opacity = 0;
                        setTimeout(function(){
                            mask.style.opacity = 1;
                        },500);

                    },
                    remove: function () {
                        var element = document.getElementById("mask");
                        element.parentNode.removeChild(element);
                    },
                    getPageSize: function () {
                        var xScroll, yScroll;
                        if (window.innerHeight && window.scrollMaxY) {
                            xScroll = window.innerWidth + window.scrollMaxX;
                            yScroll = window.innerHeight + window.scrollMaxY;
                        } else {
                            if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac        
                                xScroll = document.body.scrollWidth;
                                yScroll = document.body.scrollHeight;
                            } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari        
                                xScroll = document.body.offsetWidth;
                                yScroll = document.body.offsetHeight;
                            }
                        }
                        var windowWidth = 0;
                        var windowHeight = 0;
                        var pageHeight = 0;
                        var pageWidth = 0;
    
                        if (self.innerHeight) { // all except Explorer        
                            if (document.documentElement.clientWidth) {
                                windowWidth = document.documentElement.clientWidth;
                            } else {
                                windowWidth = self.innerWidth;
                            }
                            windowHeight = self.innerHeight;
                        } else {
                            if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode        
                                windowWidth = document.documentElement.clientWidth;
                                windowHeight = document.documentElement.clientHeight;
                            } else {
                                if (document.body) { // other Explorers        
                                    windowWidth = document.body.clientWidth;
                                    windowHeight = document.body.clientHeight;
                                }
                            }
                        }
                        // for small pages with total height less then height of the viewport        
    
                        if (yScroll < windowHeight) {
                            pageHeight = windowHeight;
                        } else {
                            pageHeight = yScroll;
                        }
                        // for small pages with total width less then width of the viewport        
                        if (xScroll < windowWidth) {
                            pageWidth = xScroll;
                        } else {
                            pageWidth = windowWidth;
                        }
                        var arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
                        return arrayPageSize;
                    }
                };      
                
              